

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  
  <title>广州大学ACM2021第11周训练 - violet apricity</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.4.0/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.8.9","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null}}};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>violet apricity</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="广州大学ACM2021第11周训练">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-05-18 18:24" pubdate>
        2021年5月18日 晚上
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      28
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">广州大学ACM2021第11周训练</h1>
            
            <div class="markdown-body">
              <h1 id="广州大学ACM2021第11周训练"><a href="#广州大学ACM2021第11周训练" class="headerlink" title="广州大学ACM2021第11周训练"></a><a target="_blank" rel="noopener" href="https://vjudge.net/contest/437980#overview">广州大学ACM2021第11周训练</a></h1><p>闲话：很久没打周赛了（其实是没有），五个小时上线了三个小时，整体来说前面五题都很简单，不过在细节处一直没处理好，很考验心态。最后是a4题，第五题读完题就有事跑路了，不过也是道暴力枚举题，稍微二进制压缩一下而已。</p>
<h2 id="A-交易-Gym-102890I"><a href="#A-交易-Gym-102890I" class="headerlink" title="A - 交易 Gym - 102890I"></a><a target="_blank" rel="noopener" href="https://codeforces.com/gym/102890/problem/I">A - 交易 Gym - 102890I</a></h2><h3 id="题意"><a href="#题意" class="headerlink" title="题意"></a>题意</h3><p><img src="https://img-blog.csdnimg.cn/20210516082456757.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MDI4MTg2OQ==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="A"><br>大致意思是要去买三本书（一开始读成n本书），给出了价格，可以根据需要组合起来去付款，这里有个优惠，就是满500减100。</p>
<h3 id="题解"><a href="#题解" class="headerlink" title="题解"></a>题解</h3><p>既然题目说满500减100，那么久尽量去凑多组500以上的，我们可以先排序，然后从小到大组一组记录价格总和，当和大于等于500时就可以将它们分成一组。因为这里只有三本书，所以很简单就算枚举也能过，这里的方法应该是使用于n的。</p>
<h3 id="code"><a href="#code" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">1e5</span>;<br><span class="hljs-keyword">int</span> a[N];<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    <span class="hljs-keyword">int</span> d;<br>    <span class="hljs-keyword">int</span> cnt=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">while</span>(cin&gt;&gt;d)&#123;<br>        a[cnt++]=d;<br>    &#125;<br>    <span class="hljs-built_in">sort</span>(a,a+cnt);<br>    ll ans=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;<br>    ll t=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">for</span>(;i&lt;cnt&amp;&amp;a[i]&lt;<span class="hljs-number">500</span>;i++)&#123;<br>        t+=a[i];<br>        <span class="hljs-keyword">if</span>(t&gt;=<span class="hljs-number">500</span>)&#123;<br>            ans+=(t<span class="hljs-number">-100</span>);t=<span class="hljs-number">0</span>;<br>        &#125;<br>    &#125;<br>    <span class="hljs-keyword">if</span>(t&gt;<span class="hljs-number">0</span>)&#123;<br>        ans+=t;<br>    &#125;<br>    <span class="hljs-keyword">for</span>(;i&lt;cnt;i++)ans+=(a[i]<span class="hljs-number">-100</span>);<br>    cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="B-三角形-Gym-102890C"><a href="#B-三角形-Gym-102890C" class="headerlink" title="B - 三角形 Gym - 102890C "></a><a target="_blank" rel="noopener" href="https://codeforces.com/gym/102890/problem/C">B - 三角形 Gym - 102890C </a></h2><h3 id="题意-1"><a href="#题意-1" class="headerlink" title="题意"></a>题意</h3><p><img src="https://img-blog.csdnimg.cn/20210516083138257.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MDI4MTg2OQ==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="B"><br>题目要求数三角形。原本有一个大三角形，现在在由往下切n条线，再平行于地面切k条线，问此时能包含的不同三角形有多少个。一共t组样例。</p>
<h3 id="题解-1"><a href="#题解-1" class="headerlink" title="题解"></a>题解</h3><p>首先容易发现，三角形一个顶点是确定的，平行切了k刀，那么数的时候就要遍历底边，所以这里是k+1条底边，而每一边的情况是相同的，也就是说数出其中一种然后乘上k+1。<br>对于每组边，切n刀分成了n+1个小三角形，相邻若干个小三角形可以组成一个大点的三角形，所以从三角形大小入手，应该有n+1，n，n-1，~~，一直加到n-p=0，也就是最大的那个三角形，即n+1个组成的。很显然就是等差数列1加到n+1。答案再乘上上面说的k+1即可。<br>这里wa很很多遍，因为注意到答案要mod1e7，而我在计算等差数列时把/2放在了最后去计算，这完全是画蛇添足。因为等差数列结果（容易发现一定是奇数乘以偶数）取了模，所以它的奇偶性改变了，之后再去/2，那么就会有误差了，应该老老实实/2再去取模的。</p>
<h3 id="code-1"><a href="#code-1" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">1e5</span>;<br><span class="hljs-keyword">const</span> ll mod=<span class="hljs-number">1000000007</span>;<br><span class="hljs-keyword">int</span> a[N];<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    <span class="hljs-keyword">int</span> t;cin&gt;&gt;t;<br>    <span class="hljs-keyword">while</span>(t--)<br>    &#123;<br>        ll n,k;<br>        cin&gt;&gt;k&gt;&gt;n;<br>        ll ans=(((k+<span class="hljs-number">1</span>)*(k+<span class="hljs-number">2</span>)/<span class="hljs-number">2</span>)%mod*(n+<span class="hljs-number">1</span>))%mod;<br>        cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="C-算式-AtCoder-arc061-a"><a href="#C-算式-AtCoder-arc061-a" class="headerlink" title="C - 算式 AtCoder - arc061_a"></a><a target="_blank" rel="noopener" href="https://vjudge.net/contest/437980#problem/C">C - 算式 AtCoder - arc061_a</a></h2><h3 id="题意-2"><a href="#题意-2" class="headerlink" title="题意"></a>题意</h3><p>给你一个只含 1 ~ 9 的 字符串s，字符串的长度小于10。你可以在任意两个字母之间插入“+”使得其成为一个合法的算式，可以一个“+”号都不插入，问你所有合法 算式 的总和.</p>
<h3 id="题解-2"><a href="#题解-2" class="headerlink" title="题解"></a>题解</h3><p>字符串很短，暴力枚举每个地方加不加加号即可。枚举时可以二进制压缩一下。</p>
<h3 id="code-2"><a href="#code-2" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">122</span>;<br><span class="hljs-keyword">const</span> ll mod=<span class="hljs-number">1000000007</span>;<br>ll dp[<span class="hljs-number">12</span>][<span class="hljs-number">12</span>];<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    string s;cin&gt;&gt;s;<br>    <span class="hljs-keyword">int</span> len=s.<span class="hljs-built_in">length</span>();<br>    ll ans=<span class="hljs-number">0</span>;<br>    ll now=<span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;(<span class="hljs-number">1</span>&lt;&lt;len<span class="hljs-number">-1</span>);i++)&#123;<br>        now=<span class="hljs-number">0</span>;<br>        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> j=<span class="hljs-number">0</span>;j&lt;len;j++)&#123;<br>            now=now*<span class="hljs-number">10</span>+s[j]-<span class="hljs-string">&#x27;0&#x27;</span>;<br>            <span class="hljs-keyword">if</span>(j==len<span class="hljs-number">-1</span>||(<span class="hljs-number">1</span>&lt;&lt;j)&amp;i)&#123;<br>                ans+=now;<br>                now=<span class="hljs-number">0</span>;<br>            &#125;<br>        &#125;<br>    &#125;<br>    cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="D-通信网络-Gym-102890D"><a href="#D-通信网络-Gym-102890D" class="headerlink" title="D - 通信网络 Gym - 102890D"></a><a target="_blank" rel="noopener" href="https://codeforces.com/gym/102890/problem/D">D - 通信网络 Gym - 102890D</a></h2><h3 id="题意-3"><a href="#题意-3" class="headerlink" title="题意"></a>题意</h3><p><img src="https://img-blog.csdnimg.cn/20210516085129973.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MDI4MTg2OQ==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="D"><br>要求翻译字符串，并且给出一个最大长度，超过了这个长度就是不合法的。<br>至于字符串格式，就是数字加字母表示该字母有多少个，只有小写字母并且一个时可以省去数字。</p>
<h3 id="题解-3"><a href="#题解-3" class="headerlink" title="题解"></a>题解</h3><p>没什么好说的，模拟即可。</p>
<h3 id="code-3"><a href="#code-3" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">1e5</span>;<br><span class="hljs-keyword">const</span> ll mod=<span class="hljs-number">1000000007</span>;<br><span class="hljs-keyword">int</span> a[N];<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    <span class="hljs-keyword">int</span> t;cin&gt;&gt;t;<br>    <span class="hljs-keyword">while</span>(t--)&#123;<br>        string s;cin&gt;&gt;s;<br>        <span class="hljs-keyword">int</span> maxn;cin&gt;&gt;maxn;<br>        string ans;<br>        <span class="hljs-keyword">int</span> len=s.<span class="hljs-built_in">length</span>();<br>        <span class="hljs-keyword">int</span> p=<span class="hljs-number">1</span>;<br>        <span class="hljs-keyword">bool</span> yes=<span class="hljs-number">1</span>;<br>        ll all=<span class="hljs-number">0</span>;<br>        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i&lt;len;)&#123;<br>            <span class="hljs-keyword">if</span>(s[i]&gt;=<span class="hljs-string">&#x27;a&#x27;</span>&amp;&amp;s[i]&lt;=<span class="hljs-string">&#x27;z&#x27;</span>)&#123;<br>                ans+=s[i];<br>                all++;<br>                i++;<br>            &#125;<br>            <span class="hljs-keyword">else</span> &#123;<br>                <span class="hljs-keyword">int</span> j=i;<br>                string temp;<br>                temp+=s[j++];<br>                <span class="hljs-keyword">while</span>(s[j]&gt;=<span class="hljs-string">&#x27;0&#x27;</span>&amp;&amp;s[j]&lt;=<span class="hljs-string">&#x27;9&#x27;</span>)temp+=s[j],j++;<br>                ll o=<span class="hljs-built_in">atoi</span>(temp.<span class="hljs-built_in">c_str</span>());<br>                all+=o;<br>                <span class="hljs-keyword">if</span>(all&gt;maxn)&#123;yes=<span class="hljs-number">0</span>;<span class="hljs-keyword">break</span>;&#125;<br>                <span class="hljs-keyword">while</span>(o--)ans+=s[j];<br>                i=j+<span class="hljs-number">1</span>;<br>            &#125;<br>            <span class="hljs-keyword">if</span>(yes==<span class="hljs-number">0</span>)<span class="hljs-keyword">break</span>;<br>        &#125;<br>        <span class="hljs-keyword">if</span>(all&gt;maxn||(s[len<span class="hljs-number">-1</span>]&gt;=<span class="hljs-string">&#x27;0&#x27;</span>&amp;&amp;s[len<span class="hljs-number">-1</span>]&lt;=<span class="hljs-string">&#x27;9&#x27;</span>))yes=<span class="hljs-number">0</span>;<br>        <span class="hljs-keyword">if</span>(yes==<span class="hljs-number">0</span>)cout&lt;&lt;<span class="hljs-string">&quot;unfeasible\n&quot;</span>;<br>        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(yes==<span class="hljs-number">1</span>)cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="E-计算单词-Gym-102890L"><a href="#E-计算单词-Gym-102890L" class="headerlink" title="E - 计算单词 Gym - 102890L "></a><a target="_blank" rel="noopener" href="https://codeforces.com/gym/102890/problem/L">E - 计算单词 Gym - 102890L </a></h2><h3 id="题意-4"><a href="#题意-4" class="headerlink" title="题意"></a>题意</h3><p><img src="https://img-blog.csdnimg.cn/2021051608554533.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MDI4MTg2OQ==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="E"><br>给出一个“子串”和“父串”的规则，即“子串”为“父串”无限循环后的子串。现给n个串，求出不同的“父串数量”。</p>
<h3 id="题解-4"><a href="#题解-4" class="headerlink" title="题解"></a>题解</h3><p>在判断归属关系时可以把父串拼接两边。先让答案对于n（视为每个串都是不相干的），遍历每个串，它与后面的串去比较，找到一个可以当它父串的，就让答案减1（这个串不是父传所以减掉），结束匹配（因为找到了就足够了）。</p>
<h3 id="code-4"><a href="#code-4" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">122</span>;<br><span class="hljs-keyword">const</span> ll mod=<span class="hljs-number">1000000007</span>;<br>pair&lt;string,string&gt;all[N];<br><span class="hljs-keyword">int</span> yes[N];<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    <span class="hljs-keyword">int</span> n;cin&gt;&gt;n;<br>    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;=n;i++)&#123;<br>        string t;cin&gt;&gt;t;<br>        string tt;tt=t+t+t;<br>        all[i]=<span class="hljs-built_in">make_pair</span>(t,tt);<br>    &#125;<br>    ll ans=n;<br>    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;=n;i++)&#123;<br>        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> j=i+<span class="hljs-number">1</span>;j&lt;=n;j++)&#123;<br>            <span class="hljs-keyword">if</span>(all[j].first.<span class="hljs-built_in">length</span>()==all[i].first.<span class="hljs-built_in">length</span>()&amp;&amp;all[j].second.<span class="hljs-built_in">find</span>(all[i].first)!=string::npos)&#123;<br>               ans--;<br>               <span class="hljs-keyword">break</span>;<br>            &#125;<br>        &#125;<br>    &#125;<br>    cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="G-选手-Gym-102890K"><a href="#G-选手-Gym-102890K" class="headerlink" title="G - 选手 Gym - 102890K"></a><a target="_blank" rel="noopener" href="https://codeforces.com/gym/102890/problem/K">G - 选手 Gym - 102890K</a></h2><h3 id="题意-5"><a href="#题意-5" class="headerlink" title="题意"></a>题意</h3><p><img src="https://img-blog.csdnimg.cn/20210516090437576.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MDI4MTg2OQ==,size_16,color_FFFFFF,t_70" srcset="/img/loading.gif" lazyload alt="G"><br>三组ABC各有一定人数，选出共k个人，C一定要选c个人，AB都得选至少一人。求选择方案数。结果对1e7取模。</p>
<h3 id="题解-5"><a href="#题解-5" class="headerlink" title="题解"></a>题解</h3><p>题目转为从C个人中选c个，A，B中选K-c个人，A，B至少选一个人的方案数。考虑直接组合数计算，然后减去A选K-c和B选K-c的方案数。（去掉A或B选不到一个人的情况）<br>注意先判断一下合理性。（选完c剩不到两个人）<br>这题难在组合数，因为结果要取模，如果按照有除法的方法可能存在除以0的情况。所以要换一种。<br>求组合数的方法有很多种，<a target="_blank" rel="noopener" href="https://blog.csdn.net/liuzibujian/article/details/81346595">可以看这里</a>。<br>因为有多组所以先预处理一下。</p>
<h3 id="code-5"><a href="#code-5" class="headerlink" title="code"></a>code</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> std;<br><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N=<span class="hljs-number">2e5</span>+<span class="hljs-number">2</span>;<br><span class="hljs-keyword">const</span> ll mod=<span class="hljs-number">1000000007</span>;<br>ll jie[N];<br>ll tow[N];<br><span class="hljs-function">ll <span class="hljs-title">power</span><span class="hljs-params">(ll a,ll b,ll p)</span>  <span class="hljs-comment">//return a^b mod p</span></span><br><span class="hljs-function"></span>&#123;<br>    ll temp = <span class="hljs-number">1</span>;<br>    <span class="hljs-keyword">while</span>(b)<br>    &#123;<br>        <span class="hljs-keyword">if</span>(b &amp; <span class="hljs-number">0x01</span>)<br>        &#123;<br>            temp = (temp * (a%p)) % p;<br>        &#125;<br>        a = ( (a%p) * (a%p) ) % p;<br>        b &gt;&gt;= <span class="hljs-number">1</span>;<br>    &#125;<br>    <span class="hljs-keyword">return</span> temp%p;<br>&#125;<br><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    jie[<span class="hljs-number">0</span>]=<span class="hljs-number">1</span>;<br>    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;N;i++)jie[i]=jie[i<span class="hljs-number">-1</span>]*i%mod;<br>    tow[N<span class="hljs-number">-1</span>]=<span class="hljs-built_in">power</span>(jie[N<span class="hljs-number">-1</span>],mod<span class="hljs-number">-2</span>,mod);<br>    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=N<span class="hljs-number">-2</span>;i&gt;=<span class="hljs-number">0</span>;i--) tow[i]=tow[i+<span class="hljs-number">1</span>]*(i+<span class="hljs-number">1</span>)%mod;<br>&#125;<br><span class="hljs-function">ll <span class="hljs-title">cal</span><span class="hljs-params">(ll n,ll m)</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-keyword">if</span>(m&gt;n) <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>    <span class="hljs-keyword">return</span> jie[n]*tow[m]%mod*tow[n-m]%mod;<br>&#125;<br><br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-comment">//IOS</span><br>    <span class="hljs-built_in">init</span>();<br>    <span class="hljs-keyword">int</span> t;cin&gt;&gt;t;<br>    <span class="hljs-keyword">while</span>(t--)&#123;<br>        ll A,B,C,k,c;<br>        ll ans=<span class="hljs-number">0</span>;<br>        cin&gt;&gt;A&gt;&gt;B&gt;&gt;C&gt;&gt;k&gt;&gt;c;<br>        <span class="hljs-keyword">if</span>(k-c&lt;<span class="hljs-number">2</span>)&#123;cout&lt;&lt;<span class="hljs-number">0</span>&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<span class="hljs-keyword">continue</span>;&#125;<br>        ll p=k-c;<br>        ll o=<span class="hljs-built_in">cal</span>(A,p)+<span class="hljs-built_in">cal</span>(B,p);o%=mod;<br>        ans=<span class="hljs-built_in">cal</span>(A+B,p)-o+mod;<br>        ans%=mod;<br>        ans*=<span class="hljs-built_in">cal</span>(C,c);<br>        ans%=mod;<br>        cout&lt;&lt;ans&lt;&lt;<span class="hljs-string">&#x27;\n&#x27;</span>;<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>下面的题没读，都是有点难度的题（也有裸题），没读就不写了。</p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/ACM/">ACM</a>
                    
                      <a class="hover-with-bg" href="/tags/%E5%B9%BF%E5%B7%9E%E5%A4%A7%E5%AD%A6/">广州大学</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/05/18/ECR109Div2/">
                        <span class="hidden-mobile">Educational Codeforces Round 109 Div. 2 2021.05.16</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.0/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js" ></script>






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/local-search.xml";
      $('#local-search-input').on('click', function() {
        searchFunc(path, 'local-search-input', 'local-search-result');
      });
      $('#modalSearch').on('shown.bs.modal', function() {
        $('#local-search-input').focus();
      });
    })()
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
